package ws.db.writetable;

import java.text.SimpleDateFormat;
import java.util.*;
import ws.db.*;

public class TestWrite {

	public static void main1(String args[]) {

		String string = "dafdasd";
		Date now = new Date();
		int d = 1;
		long longlong = 12321L;
		double double1 = 1.0;

		Object obj = now;
		Class objclass = obj.getClass();

		if (objclass.isAssignableFrom(Integer.class)) {

			System.out.println("int=" + Integer.class + " \t" + obj);

		} else if (objclass.isAssignableFrom(String.class)) {

			System.out.println("String=" + String.class + " \t" + obj);

		} else if (objclass.isAssignableFrom(Date.class)) {
			SimpleDateFormat dateformat1 = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss.S");
			String a1 = dateformat1.format(obj);
			System.out.println("Date=" + Date.class + " \t" + a1);
		} else if (objclass.isAssignableFrom(Long.class)) {

			System.out.println("long=" + Long.class + " \t" + obj);

		} else if (objclass.isAssignableFrom(Double.class)) {

			System.out.println("double=" + Double.class + " \t" + obj);

		} else {

			System.out.println("nothing");
		}

	}

	public static void main(String args[]) {
		
		
		
		ParamClass paramClass = new ParamClass();

		paramClass.setDateType(new Date());
		paramClass.setDoubleType(2.0);
		paramClass.setIntType(1004);
		paramClass.setLongType(1004L);
		paramClass.setStringType("12345678");
		paramClass.setTextType("text");
		paramClass.setVarcharType("varchar");
		paramClass.setBooleanType(true);
		
		System.out.println(paramClass);

		ArrayList<ColumnAttrPair> custom = ParamClass.columnAttrPairs;
		/*ColumnAttrPair removeVarchar = new ColumnAttrPair("Tvarchar", null);
		ColumnAttrPair removeText = new ColumnAttrPair("Ttext", null);

		custom.remove(removeVarchar);
	    custom.remove(removeText);*/

		Iterator its = custom.iterator();
		while (its.hasNext()) {
			ColumnAttrPair each = (ColumnAttrPair) its.next();
			System.out.println(each);
		}
		
		WriteObject wb = new UpdateObject("TempTable"," where Tint=1004", paramClass, custom);
		boolean result = wb.operatOneRecord();
		System.out.println("result=" + result);

	}
}
